package com.tianbao54.springboot.jpa.service;

import com.tianbao54.springboot.jpa.model.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

@Service
public class CustomerService {

    @PersistenceContext
    private EntityManager entityManager;

    public void addCustomer (Customer customer) {
        entityManager.persist(customer);
    }

    public Customer findCustomerById (long id) {
        return entityManager.find(Customer.class,id);
    }
}
